from itsdangerous import TimedJSONWebSignatureSerializer
from django.conf import settings

def get_access_token(openid):
    serialezer = TimedJSONWebSignatureSerializer(settings.SECRET_KEY,
                                                 expires_in=600)
    data = {'openid':openid}
    token = serialezer.dumps(data)
    return token.decode()
def server_access_token(access_token):
    try:
        serialezer = TimedJSONWebSignatureSerializer(settings.SECRET_KEY,expires_in=600)
        dict = serialezer.loads(access_token)
    except Exception as e:
        return None
    else:
        return dict.get('openid')